package com.example.springboottest.example.thread;

import java.util.concurrent.TimeUnit;

public class ThreadJoinTest {
    public static void main(String[] args) {
        JoinThread join1 = new JoinThread();
//        join1.setDaemon(true);
        join1.setName("join1");

        JoinThread join2 = new JoinThread();
//        join2.setDaemon(true);
        join2.setName("join2");

        join1.start();
        join2.start();

        try {
//            join1.join();
//            join2.join();
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("Main Stop");
    }

}

class JoinThread extends Thread {
    @Override
    public void run() {
        try {
            System.out.println(Thread.currentThread().getName() + " start");
            TimeUnit.SECONDS.sleep(5);
            System.out.println(Thread.currentThread().getName() + " stop");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
